<?php

/**
 * 文章控制器
 *
 * @since 1.0 2014-11-7 by sutroon
 */
class ArticleAction extends BaseAction
{
    public function notice_list()
    {
        $this->display2();
    }

    public function notice_edit()
    {
        $this->itemEdit('tgeneral_article');
    }

    public function notice_edit_save()
    {
        $params = create_params();
        $params->addParam('title', 'require', '标题未填写');
        $params->addParam('content', 'require', '内容未填写');
        $params->addParam('catalogID', 'number', '类型未选择');
        $params->addParam('state', 'number', '状态未选择');
        $params->addParam('beginTime', 'require', '开始时间未选择');
        $params->addParam('endTime', 'require', '结束时间未选择');
        if ($params->hasError()) {
            $this->act_error($params->getErrors());
        }
        $params->addData('exTags','NOTICE');
        $this->itemEditSave('tgeneral_article',$params->getParams(),array('title'=>I('title')));
    }

    public function notice_delete()
    {
        $this->itemDelete('tgeneral_article');
    }

    public function notice_catalog_list()
    {
        $where = 'exTags=\'NOTICE-CATALOG\' and parentID={0}';
        if (!$this->RoleInfo['SUPERADMIN']) {
            $where .= ' and siteID=' . $this->loginData['siteID'];
        }
        $this->itemTreeList('tgeneral_catalog', $where, 0);
    }
}